home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_26 / cheer.asm next >
Assembly Source File  |  1995-01-01  |  3KB  |  68 lines

  1. code_seg        segment
  2.         assume  cs:code_seg
  3.         org     100h
  4.         jmp     start
  5. ;----------------------------------
  6. ;B/C Software                        ;Author
  7. ;520 North Stateline Rd
  8. ;Sharon, Pa 16146
  9. ;----------------------------------
  10. message1 db     'press Esc to Quit',0dh,0ah,'$'   ;Esc to end cheer
  11. message2 db     'press any other key to play$'    ;or to go again
  12. ;-----------------------------------------------------------------------------
  13.                      ;note + delay count
  14. muzic_notes  dw      2031,0008, 1809,0008, 1612,0008, 1355,0015,
  15.              dw      1612,0006, 1355,0024, 0ffffh     ;team cheer
  16. ;-----------------------------------------------------------------------------
  17. start   proc    near
  18.         mov     ah,9                 ;DOS function number to print string
  19.         mov     dx,offset message1   ;the message
  20.         int     21h                  ;DOS interrupt
  21.         mov     ah,9                 ;DOS function number to print string
  22.         mov     dx,offset message2   ;the message
  23.         int     21h                  ;DOS interrupt
  24. begin:  mov     ah,0                 ;BIOS function wait for key press
  25.         int     16h                  ;BIOS interrupt
  26.         cmp     ah,1                 ;Esc scan code 
  27.         jz      done                 ;do we stop ?
  28.         call    play                 ;no call play
  29.         jmp     begin                ;go see if we do it again
  30. done:   mov     ax,4c00h             ;no exit back to DOS
  31.         int     21h                  ;DOS interrupt
  32. start   endp
  33. ;-------------------------------------------
  34. play    proc    near
  35.         cli                          ;interrupts off
  36.         lea     si,muzic_notes       ;point (si) to our note table
  37. play2:  cld                          ;must increment forward
  38.         lodsw                        ;load word into ax and increment (si)
  39.         cmp     ax,0ffffh            ;is it ffff - if so end of table
  40.         jz      x_muzic2             ;time to quit
  41.         push    ax                   ;push our note value on the stack
  42.         mov     al,10110110xb        ;the magic number
  43.         out     43h,al               ;send it
  44.         pop     ax                   ;pop our note value off the stack
  45.         out     42h,al               ;send LSB first
  46.         mov     al,ah                ;place MSB in al
  47.         out     42h,al               ;send it next
  48.         in      al,61h               ;get value to turn on speaker
  49.         or      al,00000011xb        ;OR the gotten value
  50.         out     61h,al               ;now we turn on speaker
  51.         lodsw                        ;load the repeat loop count into (ax)
  52. loop6:  mov     cx,10000             ;first delay count
  53. loop7:  loop    loop7                ;do the delay
  54.         dec     ax                   ;decrement repeat count
  55.         jnz     loop6                ;if not = 0 loop back
  56.         in      al,61h               ;all done
  57.         and     al,11111100xb        ;number turns speaker off
  58.         out     61h,al               ;send it
  59.         mov     cx,5000              ;second delay count
  60. loop8:  loop    loop8                ;wait a bit before next note
  61.         jmp     short play2          ;now go do next note
  62. x_muzic2:
  63.         sti                          ;enable interrupts
  64.         ret
  65. play    ends
  66. ;-------------------------------------------
  67. code_seg        ends
  68.